﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using ThanhTu.GNC.Media.KQXS.DataAccess.DAL;
using ThanhTu.GNC.Media.KQXS.DataAccess.DO;
using ThanhTu.GNC.Media.KQXS.Common;
using System.Data;

namespace GNCMedia.KQXS.MenuPage
{
    public partial class Phantich2SobatKy : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                if (!IsPostBack)
                {
                    ProvinceDAL province = new ProvinceDAL();
                    List<ProvinceDO> alldata = province.selectadd();

                    drl_tinhthanhpho_dudoan2sobatky.DataSource = alldata;
                    drl_tinhthanhpho_dudoan2sobatky.DataTextField = "princeName";
                    drl_tinhthanhpho_dudoan2sobatky.DataValueField = "provinceID";
                    drl_tinhthanhpho_dudoan2sobatky.DataBind();

                    for (int i = 1; i <= 31; i++)
                    {
                        if (i < 10)
                        {
                            drl_begin_dudoan.Items.Add("0" + i.ToString());
                            drl_Date_dudoan2sobatky_end.Items.Add("0" + i.ToString());
                        }
                        else
                        {
                            drl_begin_dudoan.Items.Add(i.ToString());
                            drl_Date_dudoan2sobatky_end.Items.Add(i.ToString());
                        }
                    }
                    for (int i = 1; i <= 12; i++)
                    {
                        if (i < 10)
                        {
                            drl_month_dudoan2sobatky_begin.Items.Add("0" + i.ToString());
                            drl_month_dudoan2sobatky_end.Items.Add("0" + i.ToString());
                        }
                        else
                        {
                            drl_month_dudoan2sobatky_begin.Items.Add(i.ToString());
                            drl_month_dudoan2sobatky_end.Items.Add(i.ToString());
                        }
                    }

                    for (int i = 2007; i < 2024; i++)
                    {
                        drl_year_dudoan2sobatky_begin.Items.Add(i.ToString());
                        drl_year_dudoan2sobatky_end.Items.Add(i.ToString());
                    }
                }

            }
            catch (Exception ex)
            {
                Response.Write("Error load province at phan tich 2 so bat ky:" + ex);
            }
            finally
            {

            }
        }

        protected void ImageButton_phantich2sobatky_Click(object sender, ImageClickEventArgs e)
        {
            try
            {
                lb_tenxo_phantich.Text = drl_tinhthanhpho_dudoan2sobatky.SelectedItem.Text;
                lb_capso_phantich.Text = txt_input_phantich2so.Text;
                string starttime = drl_begin_dudoan.SelectedItem.Text + "/" + drl_month_dudoan2sobatky_begin.SelectedItem.Text + "/" + drl_year_dudoan2sobatky_begin.SelectedItem.Text;
                string endtime = drl_Date_dudoan2sobatky_end.SelectedItem.Text + "/" + drl_month_dudoan2sobatky_end.SelectedItem.Text + "/" + drl_year_dudoan2sobatky_end.SelectedItem.Text;
                lb_tungay.Text = starttime;
                lb_denngay.Text = endtime;
                ResultLotteryDAL vReport = new ResultLotteryDAL();
                DataTable dtReport = vReport.Statistic_2SPEC(txt_input_phantich2so.Text.Trim(), drl_tinhthanhpho_dudoan2sobatky.SelectedValue, Utils.ToDateTime(starttime), Utils.ToDateTime(endtime));
                int i = dtReport.Rows.Count;
                rpt_thongke_2sobatky.DataSource = dtReport;
                rpt_thongke_2sobatky.DataBind();
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
    }
}